import java.io.*;
import java.util.*;

public class ConfigParser {
    /**
     * The properties object to load the properties file into.
     */
    private Properties prop;

    /**
     * Reads the config.properties file to be used for future parsing.
     */
    public void readConfig() {
	this.prop = new Properties();
	try {
	    this.prop.load(new FileInputStream("config.properties"));
	    //System.out.println(this.prop.toString());
	} catch(IOException e) {
	    e.printStackTrace();
	}
    }

    /**
     * Returns an array of neighbors for the given peer_ip.
     */
    public String[] getNeighbors(String peer_ip) {
	String[] peers = {"NA"};

	try {
	    String neighbors = this.prop.getProperty(peer_ip);
	    if(neighbors != null) {
		peers = neighbors.split(",");
	    }
	} catch(Exception e) {
	    e.printStackTrace();
	}
	
	return peers;
    }
}